<script setup>
import * as IndustrialComplexService from '@/api/visual/industrialComplex'
import IntelligentIntegrationMachine1 from './IntelligentIntegration-machine1.vue'
import IntelligentIntegrationMachine2 from './IntelligentIntegration-machine2.vue'
import IntelligentIntegrationMachine3 from './IntelligentIntegration-machine3.vue'
import IntelligentIntegrationMachine4 from './IntelligentIntegration-machine4.vue'
import IntelligentIntegrationMachine5 from './IntelligentIntegration-machine5.vue'
import IntelligentIntegrationMachine6 from './IntelligentIntegration-machine6.vue'

import moment from 'moment'
const pageData = ref({
  machine1: {
    config: {},
    key: 1,
    tAnimationConfig: {
      Basis: 'x',
      Duration: 2000,
      Length: 99
    }
  },
  machine2: {
    config: {},
    key: 1,
    data: [],
    tAnimationConfig: {
      Basis: 'x',
      Duration: 2000,
      Length: 99
    }
  },
  machine3: {
    config: {},
    key: 1,
    data: [],
    tAnimationConfig: {
      Basis: 'x',
      Duration: 2000,
      Length: 99
    }
  },
  machine4: {
    config: {},
    key: 1,
    data: [],
    tAnimationConfig: {
      Basis: 'x',
      Duration: 2000,
      Length: 99
    }
  },
  machine5: {
    config: {},
    key: 1,
    data: [],
    tAnimationConfig: {
      Basis: 'x',
      Duration: 2000,
      Length: 99
    }
  }
})
const loadMachine1 = async () => {
  const { data } = await IndustrialComplexService.loadIndustrialComplexMachine1()
  const { config1, config2, data3, data4, data5, config3 } = data

  config2.series[0].label.formatter = params => {
    return ` ${moment(params.value[0]).format('DD')}`
  }

  pageData.value.machine1.config = config1
  pageData.value.machine2.config = config2
  pageData.value.machine5.config = config3
  pageData.value.machine2.data = data3
  pageData.value.machine3.data = data4
  pageData.value.machine4.data = data5

  pageData.value.machine1.key++
  pageData.value.machine4.key++
}

const loadData = async () => {
  Promise.all([loadMachine1()])
}
onMounted(loadData)
</script>

<template>
  <div class="IntelligentIntegration4">
    <div class="dom1">
      <IntelligentIntegrationMachine1
        :options="pageData.machine1.config"
        :key="pageData.machine1.key"
      ></IntelligentIntegrationMachine1>
    </div>
    <div class="dom2">
      <IntelligentIntegrationMachine3 :data="pageData.machine3.data"></IntelligentIntegrationMachine3>

      <div style="overflow: hidden;">
        <IntelligentIntegrationMachine4
        :key="pageData.machine4.key"
        :data="pageData.machine4.data"
      ></IntelligentIntegrationMachine4>
      </div>
    </div>
    <div class="dom3">
      <IntelligentIntegrationMachine5 :options="pageData.machine5.config"></IntelligentIntegrationMachine5>
    </div>
    <div class="dom4">
      <IntelligentIntegrationMachine2
        :options="pageData.machine2.config"
        :data="pageData.machine2.data"
      ></IntelligentIntegrationMachine2>
    </div>
    <div class="dom5">
      <IntelligentIntegrationMachine6></IntelligentIntegrationMachine6>
    </div>
  </div>
</template>

<style scoped lang="scss">
.IntelligentIntegration4 {
  flex: 1;
  width: 100%;
  height: 100%;
  display: grid;

  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-rows: 50% 50%;
  gap: 10px;

  .dom2,
  .dom1,
  .dom3,
  .dom4,
  .dom5 {
    min-height: 0;
    overflow: hidden;
  }

  .dom4 {
    min-height: 0;
    min-width: 0;

    overflow: hidden;
  }

  .dom2 {
    height: 100%;
    grid-column: 2 / 4;
    grid-row: 1/3;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 120px 1fr;
  }

  .dom2-content {
    height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 120px 1fr;
    min-height: 0;
    overflow: hidden;
  }
}
.dom-box {
  display: flex;
  flex-direction: column;
  height: 100%;

  .dom-title {
    height: 40px;
    background-color: rgba(14, 58, 119, 0.6);
    color: #2ca7e2;
    line-height: 40px;
    padding-left: 20px;
  }

  .dom-content {
    flex: 1;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .chart-content {
    flex: 1;
    overflow: hidden;

    height: calc(100% - 70px);
  }
}

:deep(.dv-button-wrapper .dv-button) {
  padding: 0px;
}

:deep(.dv-button) {
  width: 100%;
  height: 100%;
  .dv-button-text {
    width: 100%;
    height: 100%;
  }
}

:deep(.my-box7.dv-border-box-7) {
  box-shadow: initial !important;
}
</style>
